﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.CommonMethodServiceRef;

    public class GlobalHistoryStockRptQuery : BasePage
    {
        protected Button btnSearch;
        protected DropDownList ddlDescr;
        protected DropDownList ddlExpiryDateOper;
        protected DropDownList ddlExternalLotOper;
        protected DropDownList ddlLocationIDOper;
        protected DropDownList ddlLotAttribute01;
        protected DropDownList ddlLotAttribute02;
        protected DropDownList ddlLotAttribute03;
        protected DropDownList ddlLotAttribute04;
        protected DropDownList ddlLotAttribute05;
        protected DropDownList ddlLotAttribute06;
        protected DropDownList ddlLotAttribute07;
        protected DropDownList ddlLotAttribute08;
        protected DropDownList ddlLotAttribute09;
        protected DropDownList ddlLotAttribute10;
        protected DropDownList ddlLotOper;
        protected DropDownList ddlLpnIDOper;
        protected DropDownList ddlOwnerID;
        protected DropDownList ddlProduceDateOper;
        protected DropDownList ddlReceiptDateOper;
        protected DropDownList ddlSku;
        protected DropDownList ddlSkuClassID;
        protected DropDownList ddlVendorIDOper;
        protected HtmlForm F13720;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlInputHidden hdnWh;
        protected HtmlImage imgExpiryDate;
        protected HtmlImage imgProduceDate2;
        protected HtmlImage imgReceiptDate;
        protected Label lblDescr;
        protected Label lblExpiryDate;
        protected Label lblExternalLot;
        protected Label lblInvDate;
        protected Label lblLocationID;
        protected Label lblLot;
        protected Label lblLotAttribute02;
        protected Label lblLotAttribute03;
        protected Label lblLotAttribute04;
        protected Label lblLotAttribute05;
        protected Label lblLotAttribute06;
        protected Label lblLotAttribute07;
        protected Label lblLotAttribute08;
        protected Label lblLotAttribute09;
        protected Label lblLotAttribute1;
        protected Label lblLotAttribute10;
        protected Label lblLpnID;
        protected Label lblMsg;
        protected Label lblOwnerID;
        protected Label lblProduceDate;
        protected Label lblReceiptDate;
        protected Label lblSku;
        protected Label lblSkuClassID;
        protected Label lblVendorID;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected TextBox txtDescr;
        protected TextBox txtExpiryDate;
        protected TextBox txtExpiryDate2;
        protected TextBox txtExternalLot;
        protected TextBox txtInvDate;
        protected TextBox txtLocationID;
        protected TextBox txtLot;
        protected TextBox txtLotAttribute01;
        protected TextBox txtLotAttribute02;
        protected TextBox txtLotAttribute03;
        protected TextBox txtLotAttribute04;
        protected TextBox txtLotAttribute05;
        protected TextBox txtLotAttribute06;
        protected TextBox txtLotAttribute07;
        protected TextBox txtLotAttribute08;
        protected TextBox txtLotAttribute09;
        protected TextBox txtLotAttribute10;
        protected TextBox txtLpnID;
        protected TextBox txtOwnerID;
        protected TextBox txtProduceDate;
        protected TextBox txtProduceDate2;
        protected TextBox txtReceiptDate;
        protected TextBox txtReceiptDate2;
        protected TextBox txtSku;
        protected TextBox txtSkuClassID;
        protected TextBox txtVendorID;

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtInvDate.Text.Trim()))
            {
                this.lblMsg.Text = "库存日期为必输!";
            }
            else
            {
                base.Server.Transfer("GlobalHistoryStockRptList.aspx", false);
            }
        }

        public string GetUserWh()
        {
            List<WareHouseName4DDL> WareHouseName = new List<WareHouseName4DDL>();
            if (base.DataGridViewState != null)
            {
                WareHouseName = base.DataGridViewState as List<WareHouseName4DDL>;
            }
            else
            {
                WareHouseName = CommoneMethodServiceClientProxy.GetInstance().GetUserPermissionWareHouse();
                if ((WareHouseName != null) && (WareHouseName.Count > 0))
                {
                    base.DataGridViewState = WareHouseName;
                }
            }
            StringBuilder strHtml = new StringBuilder();
            if (WareHouseName.Count > 0)
            {
                strHtml.Append(" <tr><td colspan=4 >");
                foreach (WareHouseName4DDL info in WareHouseName)
                {
                    this.hdnWh.Value = this.hdnWh.Value + info.DbLoginID + ";";
                    strHtml.AppendFormat("<input id=\"cbk{0}\" type=\"checkbox\" onclick=\"CheckWh(this,'{2}');\" checked=\"true\" />{1}&nbsp;&nbsp;", info.WhDbID, info.WhDbDesc, info.DbLoginID);
                }
                strHtml.Append(" <td><tr>");
            }
            return strHtml.ToString();
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlOwnerID, 0);
            base.InitQueryDDL(this.ddlSku, 0);
            base.InitQueryDDL(this.ddlVendorIDOper, 0);
            base.InitQueryDDL(this.ddlSkuClassID, 0);
            base.InitQueryDDL(this.ddlDescr, 0);
            base.InitQueryDDL(this.ddlLotOper, 0);
            base.InitQueryDDL(this.ddlLocationIDOper, 0);
            base.InitQueryDDL(this.ddlLpnIDOper, 0);
            base.InitQueryDDL(this.ddlExternalLotOper, 0);
            base.InitQueryDDL(this.ddlProduceDateOper, 1);
            base.InitQueryDDL(this.ddlExpiryDateOper, 1);
            base.InitQueryDDL(this.ddlReceiptDateOper, 1);
            base.InitQueryDDL(this.ddlLotAttribute01, 0);
            base.InitQueryDDL(this.ddlLotAttribute02, 0);
            base.InitQueryDDL(this.ddlLotAttribute03, 0);
            base.InitQueryDDL(this.ddlLotAttribute04, 0);
            base.InitQueryDDL(this.ddlLotAttribute05, 0);
            base.InitQueryDDL(this.ddlLotAttribute06, 0);
            base.InitQueryDDL(this.ddlLotAttribute07, 0);
            base.InitQueryDDL(this.ddlLotAttribute08, 0);
            base.InitQueryDDL(this.ddlLotAttribute09, 0);
            base.InitQueryDDL(this.ddlLotAttribute10, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
            }
        }

        public string Descr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDescr.Text.Trim(), this.ddlDescr.SelectedValue);
                }
                return "";
            }
        }

        public string ExpiryDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExpiryDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExpiryDate.Text, this.ddlExpiryDateOper.SelectedValue, this.txtExpiryDate2.Text.Trim(), "ExpiryDate");
                }
                return "";
            }
        }

        public string ExternalLot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternalLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternalLot.Text, this.ddlExternalLotOper.SelectedValue);
                }
                return "";
            }
        }

        public string InvDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtInvDate.Text.Trim()))
                {
                    return DateTime.Parse(this.txtInvDate.Text.Trim()).AddDays(1.0).ToString("yyyy-MM-dd");
                }
                return DateTime.Today.AddDays(1.0).ToString("yyyy-MM-dd");
            }
        }

        public string LocationID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLocationID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLocationID.Text.Trim(), this.ddlLocationIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string Lot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLot.Text.Trim(), this.ddlLotOper.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute01
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute01.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute01.Text.Trim(), this.ddlLotAttribute01.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute02
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute02.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute02.Text.Trim(), this.ddlLotAttribute02.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute03
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute03.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute03.Text.Trim(), this.ddlLotAttribute03.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute04
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute04.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute04.Text.Trim(), this.ddlLotAttribute04.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute05
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute05.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute05.Text.Trim(), this.ddlLotAttribute05.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute06
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute06.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute06.Text.Trim(), this.ddlLotAttribute06.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute07
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute07.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute07.Text.Trim(), this.ddlLotAttribute07.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute08
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute08.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute08.Text.Trim(), this.ddlLotAttribute08.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute09
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute09.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute09.Text.Trim(), this.ddlLotAttribute09.SelectedValue);
                }
                return "";
            }
        }

        public string LotAttribute10
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotAttribute10.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotAttribute10.Text.Trim(), this.ddlLotAttribute10.SelectedValue);
                }
                return "";
            }
        }

        public string LpnID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLpnID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLpnID.Text.Trim(), this.ddlLpnIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerID.SelectedValue);
                }
                return "";
            }
        }

        public string ProduceDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtProduceDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtProduceDate.Text, this.ddlProduceDateOper.SelectedValue, this.txtProduceDate2.Text.Trim(), "ProduceDate");
                }
                return "";
            }
        }

        public string ReceiptDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtReceiptDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtReceiptDate.Text, this.ddlReceiptDateOper.SelectedValue, this.txtReceiptDate2.Text.Trim(), "ReceiptDate");
                }
                return "";
            }
        }

        public string SkuClassID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuClassID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuClassID.Text.Trim(), this.ddlSkuClassID.SelectedValue);
                }
                return "";
            }
        }

        public string SkuID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSku.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSku.Text.Trim(), this.ddlSku.SelectedValue);
                }
                return "";
            }
        }

        public string VendorID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorID.Text.Trim(), this.ddlVendorIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string Wh
        {
            get
            {
                if (!string.IsNullOrEmpty(this.hdnWh.Value))
                {
                    return this.hdnWh.Value.Substring(0, this.hdnWh.Value.Length - 1);
                }
                return "";
            }
        }
    }
}

